home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
PIL
/
ImageTk.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
203 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import Tkinter
import Image
_pilbitmap_ok = None
def _pilbitmap_check():
global _pilbitmap_ok
if _pilbitmap_ok is None:
try:
im = Image.new('1', (1, 1))
Tkinter.BitmapImage(data = 'PIL:%d' % im.im.id)
_pilbitmap_ok = 1
except Tkinter.TclError:
_pilbitmap_ok = 0
except:
None<EXCEPTION MATCH>Tkinter.TclError
None<EXCEPTION MATCH>Tkinter.TclError
return _pilbitmap_ok
class PhotoImage:
def __init__(self, image = None, size = None, **kw):
if image is None:
if kw.has_key('file'):
image = Image.open(kw['file'])
del kw['file']
elif kw.has_key('data'):
StringIO = StringIO
import StringIO
image = Image.open(StringIO(kw['data']))
del kw['data']
if hasattr(image, 'mode') and hasattr(image, 'size'):
mode = image.mode
if mode == 'P':
image.load()
try:
mode = image.palette.mode
except AttributeError:
mode = 'RGB'
except:
None<EXCEPTION MATCH>AttributeError
None<EXCEPTION MATCH>AttributeError
size = image.size
(kw['width'], kw['height']) = size
else:
mode = image
image = None
if mode not in ('1', 'L', 'RGB', 'RGBA'):
mode = Image.getmodebase(mode)
self._PhotoImage__mode = mode
self._PhotoImage__size = size
self._PhotoImage__photo = apply(Tkinter.PhotoImage, (), kw)
self.tk = self._PhotoImage__photo.tk
if image:
self.paste(image)
def __del__(self):
name = self._PhotoImage__photo.name
self._PhotoImage__photo.name = None
try:
self._PhotoImage__photo.tk.call('image', 'delete', name)
except:
pass
def __str__(self):
return str(self._PhotoImage__photo)
def width(self):
return self._PhotoImage__size[0]
def height(self):
return self._PhotoImage__size[1]
def paste(self, im, box = None):
im.load()
image = im.im
if image.isblock() and im.mode == self._PhotoImage__mode:
block = image
else:
block = image.new_block(self._PhotoImage__mode, im.size)
image.convert2(block, image)
tk = self._PhotoImage__photo.tk
try:
tk.call('PyImagingPhoto', self._PhotoImage__photo, block.id)
except Tkinter.TclError:
v = None
try:
import _imagingtk as _imagingtk
try:
_imagingtk.tkinit(tk.interpaddr(), 1)
except AttributeError:
_imagingtk.tkinit(id(tk), 0)
tk.call('PyImagingPhoto', self._PhotoImage__photo, block.id)
except (ImportError, AttributeError, Tkinter.TclError):
raise
except:
None<EXCEPTION MATCH>(ImportError, AttributeError, Tkinter.TclError)
None<EXCEPTION MATCH>(ImportError, AttributeError, Tkinter.TclError)
class BitmapImage:
def __init__(self, image = None, **kw):
if image is None:
if kw.has_key('file'):
image = Image.open(kw['file'])
del kw['file']
elif kw.has_key('data'):
StringIO = StringIO
import StringIO
image = Image.open(StringIO(kw['data']))
del kw['data']
self._BitmapImage__mode = image.mode
self._BitmapImage__size = image.size
if _pilbitmap_check():
image.load()
kw['data'] = 'PIL:%d' % image.im.id
self._BitmapImage__im = image
else:
kw['data'] = image.tobitmap()
self._BitmapImage__photo = apply(Tkinter.BitmapImage, (), kw)
def __del__(self):
name = self._BitmapImage__photo.name
self._BitmapImage__photo.name = None
try:
self._BitmapImage__photo.tk.call('image', 'delete', name)
except:
pass
def width(self):
return self._BitmapImage__size[0]
def height(self):
return self._BitmapImage__size[1]
def __str__(self):
return str(self._BitmapImage__photo)
def getimage(photo):
photo.tk.call('PyImagingPhotoGet', photo)
def _show(image, title):
class UI(Tkinter.Label):
def __init__(self, master, im):
if im.mode == '1':
self.image = BitmapImage(im, foreground = 'white', master = master)
else:
self.image = PhotoImage(im, master = master)
Tkinter.Label.__init__(self, master, image = self.image, bg = 'black', bd = 0)
if not Tkinter._default_root:
raise IOError, 'tkinter not initialized'
top = Tkinter.Toplevel()
if title:
top.title(title)
UI(top, image).pack()